﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace UI
{
   
    public partial class maintain : Form
    {
        public string SerID;
        BLL.Serve bLKM = new BLL.Serve ();
        Model.Serve mLKM = new Model.Serve();
        string currSearchContent = "";
        public maintain()
        {
            InitializeComponent();
        }

        private void maintain_Load(object sender, EventArgs e)
        {
            string searchField = "StaName";

            dataGridView1.DataSource = bLKM.select(currSearchContent);
            currSearchContent = searchField + " like '%" + "未接单" + "%'";
            bindGrudView();
        }
        public void bindGrudView()
        {
            
            dgvReMassage.DataSource = bLKM.select(currSearchContent);
        }
      
        private void button2_Click(object sender, EventArgs e)
        {

        }

        private void dgvReMassage_SelectionChanged(object sender, EventArgs e)
        {
            if (dgvReMassage.CurrentRow != null)
            {
                textBox1.Text =dgvReMassage.CurrentRow.Cells[1].Value.ToString();
                textBox2.Text = dgvReMassage.CurrentRow.Cells[2].Value.ToString();
                textBox3.Text = dgvReMassage.CurrentRow.Cells[3].Value.ToString();
                textBox4.Text = dgvReMassage.CurrentRow.Cells[4].Value.ToString();
                textBox5.Text = dgvReMassage.CurrentRow.Cells[5].Value.ToString();
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            mLKM.UserID = textBox1.Text;
            mLKM.Name = textBox2.Text;
            mLKM.Number = textBox3.Text;
            mLKM.Iteams = textBox4.Text;
            mLKM.StaName = textBox5.Text;
            SerID= dgvReMassage.CurrentRow.Cells[0].Value.ToString();
            bool result = false;
            result = bLKM.update(mLKM,SerID );
            if (result)
            {
                bindGrudView();               
                MessageBox.Show("成功！");
                string currSearchContent = "";
                dataGridView1.DataSource = bLKM.select(currSearchContent);
            }
            else
                MessageBox.Show("失败！");
            
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }
    }
}
